<template>
  <view>
    <u-navbar :background="{ background: '' }" back-icon-color="#222222" title-color="#fff" title="我的" :immersive="true" :is-back="false" :border-bottom="false"></u-navbar>
    <view class="" style="width: 100%; height: 420rpx; background: url(https://wenzhen.jiangkukeji360.com/static/user/userbg.png) no-repeat; background-size: 100% 100%">
      <view class="" style="font-size: 32rpx; color: #fff; font-weight: bold; padding-top: 150rpx; padding-left: 50rpx">手机号</view>
      <view class="" style="display: flex; align-items: center; padding-left: 50rpx; padding-top: 15rpx">
        <view class="" style="font-size: 38rpx; font-weight: bold; color: #fff">
          {{ userinfo.mobile }}
        </view>
        <!-- <view class="btn" style="margin-left: 37rpx" @tap="edit">修改</view> -->
      </view>
    </view>
    <view class="" style="border-radius: 40rpx 40rpx 0px 0px; background: #f8f8f8; padding: 0 28rpx; margin-top: -90rpx">
      <view class="" style="height: 36rpx"></view>
      <view class="" style="background: #fff; border-radius: 20rpx; padding-bottom: 52rpx">
        <view class="" style="font-size: 32rpx; font-weight: bold; padding: 34rpx 0 42rpx 34rpx">常用工具</view>
        <view class="" style="display: flex; align-items: center; justify-content: space-around">
          <view class="" v-for="(i, k) in mylist" :key="k" style="text-align: center" @tap="mydoc(k)">
            <image :src="'https://wenzhen.jiangkukeji360.com/static/user/m' + k + '.png'" mode="" style="width: 48rpx; height: 48rpx"></image>
            <view class="">
              {{ i.tex }}
            </view>
          </view>
        </view>
      </view>
      <!-- 我的订单 -->
      <view class="" style="background: #fff; border-radius: 20rpx; padding-bottom: 52rpx; margin-top: 26rpx">
        <view class="" style="font-size: 32rpx; font-weight: bold; padding: 34rpx 0 42rpx 34rpx">我的订单</view>
        <view class="" style="display: flex; align-items: center; justify-content: space-around">
          <view class="" v-for="(i, k) in myorder" :key="k" style="text-align: center" @tap="myorders(k)">
            <image :src="'https://wenzhen.jiangkukeji360.com/static/user/i' + k + '.png'" mode="" style="width: 48rpx; height: 48rpx"></image>
            <view class="">
              {{ i.tex }}
            </view>
          </view>
        </view>
      </view>
      <!-- 系统操作 -->
      <view class="" style="background: #fff; border-radius: 20rpx; padding-bottom: 52rpx; margin-top: 26rpx">
        <view class="" style="font-size: 32rpx; font-weight: bold; padding: 34rpx 0 42rpx 34rpx">系统操作</view>
        <view class="" style="display: flex; align-items: center; justify-content: space-around">
          <view class="" v-for="(i, k) in xitong" :key="k" style="text-align: center" @tap="hive(k)">
            <image :src="'https://wenzhen.jiangkukeji360.com/static/user/z' + k + '.png'" mode="" style="width: 48rpx; height: 48rpx"></image>
            <view class="">
              {{ i.tex }}
            </view>
          </view>
        </view>
      </view>
    </view>

    <view class="" style="text-align: center; text-align: center; color: #18a4ff; font-size: 24rpx; margin-top: 50rpx">
      <text @tap="xieyi(3)">《注册协议》</text>
      <text>|</text>
      <text @tap="xieyi(1)">《隐私政策协议》</text>
    </view>

    <u-modal v-model="show" :content="'客服电话：' + userinfo.call_phone" :show-cancel-button="true" confirm-text="呼叫" @confirm="confirm"></u-modal>
  </view>
</template>

<script>
export default {
  data() {
    return {
      mylist: [
        {
          tex: '我的医生'
        },
        {
          tex: '患者资料'
        },
        {
          tex: '慢病管理'
        },
        {
          tex: '我的病历'
        }
      ],
      myorder: [
        {
          tex: '我的预约'
        },
        {
          tex: '购药订单'
        },
        {
          tex: '我的优惠券'
        },
        {
          tex: '实体病例'
        }
      ],
      xitong: [
        {
          tex: '账号管理'
        },
        {
          tex: '关于我们'
        },
        {
          tex: '联系客服'
        },
        {
          tex: '医院入驻'
        }
      ],
      show: false,
      userinfo: {}
    };
  },
  methods: {
    xieyi(e) {
      uni.navigateTo({
        url: '/user/detail/detail?type=' + e
      });
    },
    edit() {
      uni.navigateTo({
        url: '/user/editipone/editipone'
      });
    },
    mydoc(k) {
      if (k == 0) {
        uni.navigateTo({
          url: '/user/myhosp/myhosp'
        });
      } else if (k == 1) {
        uni.navigateTo({
          url: '/user/data/data'
        });
      } else if (k == 3) {
        uni.navigateTo({
          url: '/user/virus/virus'
        });
      } else {
        this.api({
          url: '/api/index/getDefault',
          method: 'post'
        }).then((res) => {
          // this.data=res.data
          if (!res.data) {
            uni.showToast({
              title: '请先添加患者资料',
              icon: 'none'
            });
          } else {
            uni.navigateTo({
              url: '/home/slow/slow'
            });
          }
        });
      }
    },
    myorders(k) {
      if (k == 0) {
        uni.navigateTo({
          url: '/user/mymake/mymake?type=1'
        });
      } else if (k == 1) {
        uni.navigateTo({
          url: '/user/mymake/mymake?type=2'
        });
      } else if (k == 2) {
        uni.navigateTo({
          url: '/user/yhquan/yhquan'
        });
      } else {
        uni.navigateTo({
          url: '/user/caselist/caselist'
        });
      }
    },
    hive(k) {
      if (k == 0) {
        uni.navigateTo({
          url: '/user/set/set'
        });
      } else if (k == 1) {
        uni.navigateTo({
          url: '/user/aboutmy/aboutmy'
        });
      } else if (k == 2) {
        this.show = true;
      } else {
        this.user();
        if (this.userinfo.hospital_auth == 0) {
          uni.showToast({
            title: '审核中',
            icon: 'none'
          });
        } else if (this.userinfo.hospital_auth == 1) {
          uni.showToast({
            title: '审核失败，请重新提交',
            icon: 'none'
          });
          setTimeout(() => {
            uni.navigateTo({
              url: '/pages/user/shoprz'
            });
          }, 1000);
        } else if (this.userinfo.hospital_auth == 2) {
          uni.showToast({
            title: '审核通过',
            icon: 'none'
          });
        } else {
          uni.navigateTo({
            url: '/user/shoprz/shoprz'
          });
        }
      }
    },
    confirm() {
      uni.makePhoneCall({
        phoneNumber: this.userinfo.call_phone
      });
    },
    user() {
      this.api({
        url: '/api/user/index',
        method: 'post'
      }).then((res) => {
        this.userinfo = res.data;
      });
    }
  },
  onShow() {
    this.user();
  }
};
</script>

<style>
page {
  background: #f8f8f8;
}

.btn {
  width: 78rpx;
  height: 34rpx;
  background: #ff7251;
  border-radius: 17rpx;
  line-height: 34rpx;
  text-align: center;
  color: #ffffff;
  font-size: 22rpx;
}
</style>
